<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <title>title</title>
	<link rel="stylesheet" href="../../resource/weui.min.css"/>
	<link rel="stylesheet" href="../../resource/example.css"/>
	<script src="../../template/js/jquery.js"></script>
	<script src="../../template/js/com/template.js"></script>
	<script src="../../resource/my.js"></script>
	<script src="../../script/api.js"></script>

      <link rel="stylesheet" href="../../resource/jinsuistyle.css" />
    
    <style>
    	body {
	    }
    	.bgColor {
    		
    	}
		.btn{
		 margin-bottom: 40px
		}
		.btnn{
		 width:90%;
		 font-size:20px;
		 margin:0 auto;
		 height:42px;
		 border-radius:5px;
         line-height: 42px;
		}
    </style>
</head>
<body style="background: #fcfcfc"> 
<div>
	<div style="width: 100%;height: 80%;">
		<div style="width:100%;clear:both">
		<div style="font-size: 20px;padding-top:10px;text-align: center">请选择支付方式</div>
		
		<!-- <input type="button" onclick="closeInfo()" style="font-size:xx-large;float:right;margin-right:5%;" value="&times"/> -->
		</div>
	</div>
	<div style="clear:both;bottom:0;position:absolute;width:100%;text-align:center">
		<div class="btn"><div id="btnn" class="btnn" style="background: #fff;" onclick="unionPay();">银联支付</div></div>
		
		<div class="btn"><div id="btnn" class="btnn" onclick="closeInfo();" style="background: #ff5151;color:#fff">取消</div></div>
		</div>
		</div>
		
		 <div id="loadingToast" style="display:none;">
		        <div class="weui-mask_transparent"></div>
		        <div class="weui-toast">
		            <i class="weui-loading weui-icon_toast"></i>
		            <p class="weui-toast__content">数据提交中...</p>
		        </div>
			</div>
</body>
<script type="text/javascript" src="../../script/api.js"></script>
<script type="text/javascript" src="../../resource/jquery-1.js"></script>
<script type="text/javascript" src="../../script/constants.js"></script>
<script type="text/javascript" charset="UTF-8" src="../../script/naes.js"></script>
<script src="../../script/api.js"></script>
<script type="text/javascript">
    utils = {
	    setParam : function (name,value){
	        localStorage.setItem(name,value)
	    },
	    getParam : function(name){
	        return localStorage.getItem(name)
	    }
	}
 
	function closeInfo(){
		alert("您好，您的未支付订单将在30分钟后自动取消，请及时支付！");
		if(api.systemType == "android"){
		 $api.setStorage("frame","");
		 }
		var jsfun = 'funcGoto();';
		api.execScript({
		    script: jsfun
		});
		api.closeFrame({
	    });
	    
	}
	
	function closeInfo1(){
		if(api.systemType == "android"){
		 $api.setStorage("frame","");
		 }
		var jsfun = 'funcGoto1();';
		api.execScript({
		    script: jsfun
		});
		api.closeFrame({
	    });
	    
	}
	

   	
   	function unionPay(){
   	 var jsfun = 'show();';
		api.execScript({
		    script: jsfun
		});
        var isCard = 0;
		var card = "";
   	var dl_phone = $api.getStorage("dl_phone");
   	      var callback = function(ret, err){
// 		   api.ajax({
//	              url:'http://wechat.scjinsui.com/weixin/unionPay/zfyhk.do?dl_phone='+dl_phone
//            },function(ret,err){
               var jsfun = 'hide();';
				api.execScript({
				    script: jsfun
				});
//                 console.info("------------->"+JSON.stringify(ret));
              	 if(ret){
              	   if(ret.msg == 1){
              	     cardNo = ret.cardno;
              	     cardJg = ret.qc;
              	     cardType = ret.ctype;
              	     isCard = 1;
              	     if(cardType != "" && cardType == "01"){
					     card = cardJg + "借记卡(" + cardNo + ")"; 
					  }else if(cardType != "" && cardType == "02"){
					     card = cardJg + "贷记卡(" + cardNo + ")"; 
					  }
					  $api.setStorage("card",card);
              	   }else if(ret.msg == 2){
              	     cardNo = ret.cardno;
              	     isCard = 2;
              	     card = cardNo;
              	     $api.setStorage("card",card);
              	   }
              	   
              	   if(isCard == 0){
   	   if(api.systemType=='ios'){
	       api.confirm({
	          title: '温馨提示',
	          msg:'对不起，您还没绑定银行卡，请先绑定银行卡！',
	          buttons: ['去绑卡', '暂时不用']
	        }, function(ret, err) {
	          var index = ret.buttonIndex;
	          if(index==1){
	          api.openWin({
					name: 'card',
	                url:"http://wechat.scjinsui.com/weixin/wx/unionPay/card_add.jsp?dlPhone="+dl_phone
	                //url:"http://192.168.85.32:8181/wx/unionPay/card_add.jsp?dlPhone="+dl_phone
	                });
	          }
	        });
	      }else{
	        var r=confirm("您还没有绑卡哦，确定现在去绑卡吗？");
	        if(r){
	           window.setTimeout(function(){
			       api.closeWin({});
			  },1000)
	          api.openWin({
					name: 'card',
	                url:"http://wechat.scjinsui.com/weixin/wx/unionPay/card_add.jsp?dlPhone="+dl_phone
	                //url:"http://192.168.85.32:8181/wx/unionPay/card_add.jsp?dlPhone="+dl_phone
	          });
	        }
	      }
   	 }else{
   	 	
   	   if(api.systemType == "android"){
		 $api.setStorage("frame","");
		 }
		var jsfun = 'uPay();';
		api.execScript({
		    script: jsfun
		});
		api.closeFrame({
	    });
	  }
              	 }
//              });
      }
      var parameter = {"dl_phone":dl_phone};
      apiAjax(JSON.stringify(parameter),url.zcylzf,callback);
   	}
   	
  
</script>
</html>